/*******************************************************************************
* Copyright (C) 2013 Spansion LLC. All Rights Reserved. 
*
* This software is owned and published by: 
* Spansion LLC, 915 DeGuigne Dr. Sunnyvale, CA  94088-3453 ("Spansion").
*
* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND 
* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
*
* This software contains source code for use with Spansion 
* components. This software is licensed by Spansion to be adapted only 
* for use in systems utilizing Spansion components. Spansion shall not be 
* responsible for misuse or illegal use of this software for devices not 
* supported herein.  Spansion is providing this software "AS IS" and will 
* not be responsible for issues arising from incorrect user implementation 
* of the software.  
*
* SPANSION MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), 
* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, 
* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED 
* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED 
* WARRANTY OF NONINFRINGEMENT.  
* SPANSION SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, 
* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT 
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, 
* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR 
* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, 
* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, 
* SAVINGS OR PROFITS, 
* EVEN IF SPANSION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 
* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED 
* FROM, THE SOFTWARE.  
*
* This software may be replicated in part or whole for the licensed use, 
* with the restriction that this Disclaimer and Copyright notice must be 
* included with each copy of this software, whether used in part or whole, 
* at all times.  
*****************************************************************************/
/** \file ram_size.h
 **
 ** MCU description file
 **
 ** History:
 ** 2015-02-03  1.00  FTo   First version
 *****************************************************************************/
#ifndef __RAM_SIZE_H__
#define __RAM_SIZE_H__

/*****************************************************************************/
/* Include files                                                             */
/*****************************************************************************/

/*****************************************************************************/
/* Global pre-processor symbols/macros ('#define')                           */
/*****************************************************************************/
#define RAM_XBS_START_ADDR      0x00010000
#define RAM_BCKP_START_ADDR     0x00004000
#define RAM_BCKP_END_ADDR       0x00006000
#define BACKUP_RAM_FULLSIZE     0x2000

#if     defined(__CPU_MB91F591__)           || \
        defined(__CPU_MB91F591S__)          || \
        defined(__CPU_MB91F591_FR80__)      || \
        defined(__CPU_MB91F591S_FR80__) 
    #define XBS_RAM_FULLSIZE 0xA000      // 40kB RAM
#elif   defined(__CPU_MB91F592__)           || \
        defined(__CPU_MB91F592S__)          || \
        defined(__CPU_MB91F592_FR80__)      || \
        defined(__CPU_MB91F592S_FR80__) 
    #define XBS_RAM_FULLSIZE 0xA000      // 40kB RAM
#elif   defined(__CPU_MB91F594__)           || \
        defined(__CPU_MB91F594S__)          || \
        defined(__CPU_MB91F594_FR80__)      || \
        defined(__CPU_MB91F594S_FR80__) 
    #define XBS_RAM_FULLSIZE 0x10000     // 64kB RAM
#elif   defined(__CPU_MB91F596__)           || \
        defined(__CPU_MB91F596S__)          || \
        defined(__CPU_MB91F596_FR80__)      || \
        defined(__CPU_MB91F596S_FR80__) 
    #define XBS_RAM_FULLSIZE 0xA000      // 40kB RAM
#elif   defined(__CPU_MB91F597__)           || \
        defined(__CPU_MB91F597S__)          || \
        defined(__CPU_MB91F597_FR80__)      || \
        defined(__CPU_MB91F597S_FR80__) 
    #define XBS_RAM_FULLSIZE 0xA000      // 40kB RAM
#elif   defined(__CPU_MB91F599__)           || \
        defined(__CPU_MB91F599S__)          || \
        defined(__CPU_MB91F599_FR80__)      || \
        defined(__CPU_MB91F599S_FR80__) 
    #define XBS_RAM_FULLSIZE 0x10000     // 64kB RAM
#elif   defined(__CPU_MB91F59AC__)          || \
        defined(__CPU_MB91F59ACS__)         || \
        defined(__CPU_MB91F59ACH__)         || \
        defined(__CPU_MB91F59ACHS__)        || \
        defined(__CPU_MB91F59AC_FR80__)     || \
        defined(__CPU_MB91F59ACS_FR80__)    || \
        defined(__CPU_MB91F59ACH_FR80__)    || \
        defined(__CPU_MB91F59ACHS_FR80__)   
    #define XBS_RAM_FULLSIZE 0x30000     // 192kB RAM
#elif   defined(__CPU_MB91F59BC__)          || \
        defined(__CPU_MB91F59BCS__)         || \
        defined(__CPU_MB91F59BCH__)         || \
        defined(__CPU_MB91F59BCHS__)        || \
        defined(__CPU_MB91F59BC_FR80__)     || \
        defined(__CPU_MB91F59BCS_FR80__)    || \
        defined(__CPU_MB91F59BCH_FR80__)    || \
        defined(__CPU_MB91F59BCHS_FR80__)   
    #define XBS_RAM_FULLSIZE 0x30000     // 192kB RAM
#else
    #error "No valid MCU Device selected!"
#endif
    #define RAM_XBS_END_ADDR (RAM_XBS_START_ADDR + XBS_RAM_FULLSIZE - 4)


#define RAM_BLOCKSIZE               0x1000 // 4 kB: size of one RAM block
#define XBS_RAM_BLOCK_COUNT         XBS_RAM_FULLSIZE / RAM_BLOCKSIZE
#define BACKUP_RAM_BLOCK_COUNT      BACKUP_RAM_FULLSIZE / RAM_BLOCKSIZE

#if(XBS_RAM_FULLSIZE % RAM_BLOCKSIZE != 0)
    #error "XBS_RAM_BLOCK_COUNT value invalid. Value must be integer"
#endif

#if(BACKUP_RAM_FULLSIZE % RAM_BLOCKSIZE != 0)
    #error "BACKUP_RAM_BLOCK_COUNT value invalid. Value must be integer"
#endif

#endif /* __RAM_SIZE_H__ */
